import Base64 from '@/lib/base64.min'
import WxInfoVO from './wxInfoVO'

/**
 * 用户信息对象
 */
export default {
  encode: function (userVO) {
    if (!userVO) return null
    try {
      if (userVO.ShowName) {
        userVO.ShowName = Base64.encode(userVO.ShowName)
      }
    } catch (error) {
      window.console.log('base64 encode error: userVO')
    }
    if (userVO.WxInfo) {
      WxInfoVO.encode(userVO.WxInfo)
    }
    return userVO
  },

  decode: function (userVO) {
    if (!userVO) return null
    try {
      userVO.ShowName = Base64.decode(userVO.ShowName)
    } catch (error) {
      window.console.log('base64 decode error: userVO')
    }
    if (userVO.WxInfo) {
      WxInfoVO.decode(userVO.WxInfo)
    }
    return userVO
  }
}
